package com.xwl.learn.chapter05;

public class lianxiti {
    /**
     * 题目1：
     * int  m = 1 , n = 2, o = 3 ,p = 4;
     * System.out.println("ok = "+  ((m + n) *o /(p - o) + p) );
     * System.out.println("ok = "+  (m + n) *o /(p - o) + p );
     * System.out.println("ok = "+  p % n );
     * System.out.println("ok = " +( m > n));
     * System.out.println("ok = " + (p >= p));
     * System.out.println("ok = " + (p != p));
     */
    //1、9/5  2、13 3、0  4、false  5、true  6、false
    public void lx01() {
        int m = 1, n = 2, o = 3, p = 4;
        System.out.println("ok = " + ((m + n) * o / (p - o) + p));
        System.out.println("ok = " + (m + n) * o / (p - o) + p);
    }

    public void lx02() {
        /**
         *题目2：
         *         int  m = 1 , n = 2, o = 3 ,p = 4;
         *         System.out.println("ok = " +((p > m )&&(p < m)));  false
         *         System.out.println("ok = " +((p > m )||(p < m)));  true
         *         boolean OK = (p != p) && (n < o);
         *         System.out.println(OK );      false
         *         boolean Ok = (p != p) || (n < o);
         *         System.out.println(Ok );  true
         * */
        int m = 1, n = 2, o = 3, p = 4;
        System.out.println("ok = " + ((p > m) && (p < m)));
        System.out.println("ok = " + ((p > m) || (p < m)));
        boolean OK = (p != p) && (n < o);
        System.out.println(OK);
        boolean Ok = (p != p) || (n < o);
        System.out.println(Ok);
    }

    public void test03() {
        /**
         * */
        boolean a, b, c;
        a = true;
        b = false;
        c = a & b;
        System.out.println(c);
        c = a | b;
        System.out.println(c);
        c = a ^ b;
        System.out.println(c);
        c = !a;
        System.out.println(c);
        c = a && b;
        System.out.println(c);
        c = a || b;
        System.out.println(c);
    }

    public void lx04() {
        int i = 1;
        int j = 2;
        char c = 'c';
        int a = 10;
        boolean flag1 = (i < 3) && (i + j) > 5;
        boolean flag2 = (i < 2) || (i + j) < 6;
        System.out.println(flag1);
        System.out.println(flag2);
        System.out.println(c + a);
    }

    /**
     * 1、设有如下变量，以下哪些语句编译不出错? (ab)
     * char c = ‘c’;
     * int i = 10;
     * double d = 10;
     * long l = 1;
     * String s = “Hello”;
     * int a = 2;
     * A. c=c+i;109 B. s+=i; C. i+=s; D.c+=s;
     */
    public void lx05() {
        int a = 3;
        System.out.println(a+=a*=a);

    }
    /** 2、若有 a=3,则执行下列语句为a的值为？ a+=a*=a; (b)
     * A. 3 B. 12 C. 9 D.18
     *
     * 3、下面的运算符中，用于执行除法运算是哪个？(a)
     * A. / B. \ C. % D.*
     *
     * 4、下面代码的输出结果为？(d)
     * int m = 5,n = 6;
     * int x = (m++) + n;
     * int y =(-–m) + n;
     * System.out.print(“x=” + x+ “,”);
     * System.out.println(“y” + y);
     *
     * A. x=11,y=11 B. x=10,y=11 C. x=10,y=12 D.x=12,y=10
     *
     * 5、执行下列程序段后，m,x,y的值分别是？ (b)
     * int x = 2,y = 4;
     * boolean m;
     * m = ++x > y–;
     * A. true,2,4 B. false,3,3 C. true,3,3 D.false,2,4
     *
     * 6、下列程序段执行后，k的结果是？(b)
     * int a = 9,b = 11,k;
     * k=a!=b?a+b:a-b;
     * 9!=11?20:-2
     * A. -2 B. 20 C. 11 D.9*/
    public static class MathDemo {

        public static void main(String[] args) {
            //将变量m的初值赋值为10，变量n的初值赋值为5
            int m = 10,n = 5;
            //变量m的值加3，n的值加5
            m = m+3;n = n+5;
            //求m和n的平均值，并将结果存于变量p中
            double p = (m+n)/2;
            //求m的平方乘以n的平方，并将结果存于变量q中
            int q = (m^2)+(n^2);
            //将p和q的值打印输出
            System.out.println("p="+p);
            System.out.println("q="+q);
        }
    }
    public static class SuanShuDemo {

        public static void main(String[] args) {
            //声明三个整型变量a、b、c
            int a,b,c;
            //分别为a,b,c赋值为4,15,20
            a=4;b=15;c=20;
            //计算(b/a)+c的值 ，并赋值给变量m
            double m = (b/a)+c;
            //计算(c%b)*a-c的值，并赋值给变量n
            double n = (c%b)*a-c;
            //输出m和n的值
            System.out.println("m="+m);
            System.out.println("n="+n);
        }
    }
}
